var n;
Object.defineProperty(exports, "__esModule", {
  value: true
});
 //var YpNetMag = require("AA_YpNetMag");
var GameConfig = require("AA_GameConfig");
var SingletonManager = require("AA_SingletonManager");
var _def_DataManager = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t._secret_key = "secret-key";
    t._dataMap = new Map();
    return t;
  }
  __extends(_creator, e);
  _creator.prototype._save = function (e, t) {
    if (require("AA_YpNetMag").YpNetMag.isload) {
      var o = JSON.stringify(t);
      var n = this._getKey(e);
      this._setKey(n, o);
      this._dataMap.set(e, t);
      this.saveCount();
      console.log("本地保存");
      this.updateSeverData();
    }
  };
  _creator.prototype.updateSeverData = function () {
    require("AA_YpNetMag").YpNetMag.saveSeverStorage();
  };
  _creator.prototype.getSecretKey = function () {
    return this._secret_key;
  };
  _creator.prototype.getAllData = function () {
    return this._dataMap;
  };
  _creator.prototype._load = function (e) {
    var t = this._getKey(e);
    var o = cc.sys.localStorage.getItem(t);
    var n = null;
    if (o) {
      try {
        n = JSON.parse(o);
      } catch (e) {
        n = o;
      }
    }
    this._dataMap.set(e, n);
    return n;
  };
  _creator.prototype.updateDataMap = function (e, t) {
    var o = JSON.stringify(t);
    var n = this._getKey(e);
    this._setKey(n, o);
    this._dataMap.set(e, t);
  };
  _creator.prototype.saveCount = function () {
    var e = Number(cc.sys.localStorage.getItem("gameversion"));
    e || (e = 0);
    e += 1;
    cc.sys.localStorage.setItem("gameversion", e + "");
  };
  _creator.prototype._clear = function (e) {
    var t = [];
    if (e) {
      t.push(e);
      for (var o = 0; o < t.length; o++) {
        var n = t[o];
        var i = this._getKey(n);
        this._rmKey(i);
      }
    } else {
      cc.sys.localStorage.clear();
    }
  };
  _creator.prototype._getKey = function (e) {
    if (GameConfig.default.appConfig.Publish) {
      return this._secret_key + "-release-" + e;
    } else {
      return this._secret_key + "-debug-" + e;
    }
  };
  _creator.prototype._setKey = function (e, t) {
    cc.sys.localStorage.setItem(e, t);
  };
  _creator.prototype._rmKey = function (e) {
    cc.sys.localStorage.removeItem(e);
    this._dataMap.delete(e);
  };
  _creator.prototype.isNull = function (e) {
    return null == e || null == e;
  };
  return _creator;
}(SingletonManager.SingletonMgr);
exports.default = _def_DataManager;